package com.mobile.util.config.exception;

import com.mobile.util.AppUtil;
import com.mobile.util.Const;
import com.mobile.util.MessageUtil;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.Map;

/**
 * 全局异常处理器
 *
 * @author bee
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(BusinessException.class)
    public Object businessException(BusinessException businessException) {
        Map<String, Object> map = new HashMap<>();
        map.put(Const.ACTION_RESULT, Const.ACTION_RESULT_EXCEPTION);
        map.put(Const.ACTION_MESSAGE, MessageUtil.getMessage("E0016"));
        return AppUtil.returnObject(map);
    }

}
